﻿<%@page import="org.springframework.util.StringUtils"%>
<%@page import="freemarker.template.utility.StringUtil"%>
<%@page import="com.bill.common.system.dto.OrderDTO"%>
<%@page import="com.bill.common.system.service.IOrderService"%>
<%@page import="com.bill.common.system.service.OrderService"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page import="com.bill.common.user.dto.RegUserBasicDTO"%>
<%@page import="com.bill.common.user.service.IRegisterUserService"%>
<%@page import="com.bill.common.user.dto.AccountDTO"%>
<%@page import="com.bill.common.user.service.IAccountService"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@page import="com.bill.common.utils.Verification"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
//genealogy.jsp?loginName=${regUserBasicDTO.loginName}
ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
IOrderService orderService = (IOrderService)ac.getBean("orderService");
String payMoeny = request.getParameter("payMoeny");

String MD5key; //MD5key值
MD5key = "sjPF}L{i";
String MerNo;   //商户ID
MerNo = "21234";
String BillNo;  //订单编号
BillNo = String.valueOf(System.currentTimeMillis());

OrderDTO orderDTO = new OrderDTO();
String orderId = request.getParameter("orderId"); 
if(StringUtils.hasText(orderId)){
	orderDTO = orderService.findOrderInfo(Long.parseLong(request.getParameter("orderId")));
}else{
	OrderDTO dto = new OrderDTO();
	dto.setLoginName((String)session.getAttribute("loginName"));
	dto.setOrderStatus("待支付");
	dto.setOrderNo(BillNo);
	dto.setOdesc("用户充值-皇马生态系统");
	dto.setPayMoeny(Long.parseLong(payMoeny));
	Long orderIds  = orderService.saveOrder(dto);
	orderDTO = orderService.findOrderInfo(orderIds);
}

if("已成功支付".equals(orderDTO.getOrderStatus())){
	request.getRequestDispatcher("rechargeMain.jsp").forward(request,response);
}

String Amount;  //支付金额
Amount = orderDTO.getPayMoeny()*1+"";//
//Amount="0.1";
String ReturnURL;   //返回地址
ReturnURL = "http://www.hmcft.com/user/payresult.jsp";
//[必填]返回数据给商户的地址(商户自己填写):::注意请在测试前将该地址告诉我方人员;否则测试通不过
//ReturnURL = "http://192.168.1.108/ecpss/payresult.jsp";
String tradeAdd;   //返回地址
String md5src;  //加密字符串    
md5src = MerNo + BillNo + Amount + ReturnURL + MD5key;
Verification md5 = new Verification();
String MD5info; //MD5加密后的字符串
MD5info = md5.getMD5Str(md5src).toUpperCase();//MD5检验结果
String AdviceURL ="http://www.hmcft.com/user/payadvice.jsp";  //[必填]支付完成后，后台接收支付结果，可用来更新数据库值

//送货信息(方便维护，请尽量收集！如果没有以下信息提供，请传空值:'')
//因为关系到风险问题和以后商户升级的需要，如果有相应或相似的内容的一定要收集，实在没有的才赋空值,谢谢。
//账单地址选择传递
String firstname ="M" ;  //------------------------账单地址姓
String lastname="H" ; //'-------------------账单地址的姓
String email="2683679963@qq.com" ;//'----------账单地址的Email
String phone="0218888888"; //'---------------账单地址的固定电话
String zipcode="200333"; //'----------------账单地址的邮编
String address="zhongjiang"; //'-------------账单地址具体地址
String city="shanghai";// '--------------------账单地址所在城市
String state="shanghai"; //'-------------------账单地址所在省或者州
String country="china";// '-------------------账单地址所在国
String products="会员充值-皇马生态系统";// '------------------物品信息
//发货地址尽量收集   可提高支付率
String shippingFirstName=orderDTO.getLoginName(); //'-------------------收货人的姓
String shippingLastName=""; //'-------------------收货人的名
String shippingEmail="";//'----------收货人的Email
String shippingPhone="";//'---------------收货人的固定电话
String shippingZipcode="200333" ;//'----------------收货人的邮编
String shippingAddress="zhongjiang"; //'-------------收货人具体地址
String shippingCity="shanghai";// '--------------------收货人所在城市
String shippingSstate="shanghai" ;//'-------------------收货人所在省或者州
String shippingCountry="china";// '-------------------收货人所在国家
String Remark="会员充值";


%>
<fmt:setLocale value="${empty cookie['language'].value?'zh_CN':cookie['language'].value}"/>
	<fmt:setBundle basename="i18n.itilbase"/>
	<c:set var="lang" value="${empty cookie['language'].value?'zh_CN':cookie['language'].value}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="scripts/jquery/jquery-1.4.2.min.js"></script>
<meta charset="UTF-8">
<title><fmt:message key="i18n.userCZ"/>-<fmt:message key="i18n.title"/></title>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1" />

<script type="text/javascript">
$(function(){
	$("#E_FORM").submit();	
});
</script>

</head>
<body style="height:800px">

<!-- 主体内容 -->
<div class="mainWrap">
	<div class="mwCurrent"><fmt:message key="i18n.yourlocation"/>：<fmt:message key="i18n.moneyManage"/>  &gt;   <fmt:message key="i18n.onlineCz"/></div>
	<div class="content">
	<div class="content" align="center">
		<br><br><br><br>
			<div style="font-size: 15px;color: red;" ><fmt:message key="i18n.orderInfo"/>：<fmt:message key="i18n.userCZ"/>:<%=orderDTO.getPayMoeny() %>，折合人民币：<%=orderDTO.getPayMoeny()*1 %></div>
			<br><br>
			<form action="https://pay.ecpss.com/sslpayment" method="post" id="E_FORM" name="E_FORM" target="_blank">
				<table align="center">
		
					<tr>
						<td></td>
						<td><input type="hidden" name="MerNo" value="<%=MerNo%>">
						</td>
					</tr>
					<tr>
						<td></td>
						<td><input type="hidden" name="BillNo" value="<%=BillNo%>">
						</td>
					</tr>
					<tr>
						<td></td>
						<td><input type="hidden" name="Amount" value="<%=Amount%>">
						</td>
					</tr>
		
					<tr>
						<td></td>
						<td><input type="hidden" name="ReturnURL"
							value="<%=ReturnURL%>">
						</td>
					</tr>
		
					<tr>
						<td></td>
						<td><input type="hidden" name="AdviceURL"
							value="<%=AdviceURL%>">
						</td>
					</tr>
		
					<tr>
						<td></td>
						<td><input type="hidden" name="MD5info" value="<%=MD5info%>">
						</td>
					</tr>
					<tr>
						<td></td>
						<td><input type="hidden" name="Remark" value="<%=Remark%>">
						</td>
					</tr>
					<tr>
						<td></td>
						<td><input type="hidden" name="shippingFirstName"
							value="<%=shippingFirstName%>">
						</td>
					</tr>
					<tr>
						<td></td>
						<td><input type="hidden" name="shippingLastName"
							value="<%=shippingLastName%>">
						</td>
					</tr>
					<tr>
						<td></td>
						<td><input type="hidden" name="shippingEmail"
							value="<%=shippingEmail%>">
						</td>
					</tr>
					<tr>
						<td></td>
						<td><input type="hidden" name="shippingPhone"
							value="<%=shippingPhone%>">
						</td>
					</tr>
					<tr>
						<td></td>
						<td><input type="hidden" name="shippingZipcode"
							value="<%=shippingZipcode%>">
						</td>
					</tr>
					<tr>
						<td></td>
						<td><input type="hidden" name="shippingAddress"
							value="<%=shippingAddress%>">
						</td>
					</tr>
					<tr>
						<td></td>
						<td><input type="hidden" name="shippingCity"
							value="<%=shippingCity%>">
						</td>
					</tr>
					<tr>
						<td></td>
						<td><input type="hidden" name="shippingSstate"
							value="<%=shippingSstate%>">
						</td>
					</tr>
					<tr>
						<td></td>
						<td><input type="hidden" name="shippingCountry"
							value="<%=shippingCountry%>">
						</td>
					</tr>
					<tr>
						<td></td>
						<td><input type="hidden" name="products" value="<%=products%>">
						</td>
					</tr>
				</table>
				<p align="center">
				<c:if test="${maps.paytype ne 'staticaddpay'}"></c:if>
				<input type="submit" style="height: 30px;width: 300px;" name="b1" value="网上银行支付">
				<!--  
				<br><br><input type="button" style="height: 30px;width: 300px;" name="b1" onclick="window.location.href='companyFinancial.jsp?paytype=${maps.paytype}'" value="财付通支付(财付通充值提现。无需手续费)">&nbsp;
				-->
				</p>
			</form>
		<br><br><br><br>
	</div>
</div>

</div>

</body>
</html>